package org.jmx;

import javax.management.*;
import java.lang.management.ManagementFactory;

public class TeacherMXBeanManagement {

    public static void main(String[] args) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException, InterruptedException {
        MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        ObjectName teacher_objectName = new ObjectName("org.jmx:type=Teacher");
        Book book = new Book("java书", 30);
        Teacher teacher = new Teacher(27, "pop", "66");
        teacher.addBook(book);
        mBeanServer.registerMBean(teacher, teacher_objectName);
        Thread.sleep(Long.MAX_VALUE);
    }
}
